package Adaptateurs;

import java.awt.Color;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

import Adaptateurs.PlateauAdaptateur.objets;
import Controleur.ControllerSimulation;
import Controleur.Controlleur;


public class CaseVue extends JLabel implements MouseListener
{
	private int abssise;

	private int ordonnee;
	
	private final Color fond = new Color(37,162,44);
	
	private Controlleur controlleur;
	
	private static final Icon Iconfourmi = new ImageIcon("./img/Fourmi.png");
	public static final Icon IconSelectionne = new ImageIcon("./img/selectionne.png");
	
	public CaseVue(int X, int Y, Controlleur cont) {
		super();
		
		
		this.abssise = X;
		this.ordonnee = Y;
		controlleur = cont;
		
		this.setText("");
		this.setToolTipText("vide");
		this.addMouseListener(this);

	}
	
	public int getAbssisse() {
		return this.abssise;
	}
	
	public int getOrdonnee() {
		return this.ordonnee;
	}
	
	public void setObject (PlateauAdaptateur.objets objet)
	{
		switch (objet) {
		case fourmi:
			this.setForeground(Color.GREEN);
			this.setIcon(Iconfourmi);
			break;
		case fourmiliere:
			this.setForeground(Color.GREEN);
			this.setIcon(new ImageIcon("./img/Fourmilliere.png"));
			break;
		case nourriture:
			this.setForeground(Color.GREEN);
			this.setIcon(new ImageIcon("./img/Nourriture.png"));
			break;
		case pheromone:
//			this.setForeground(new Color(.67f,.61f,.54f,1f ));
			this.setForeground(Color.PINK);
			this.setText("P");
			this.setIcon(null);
//			this.setOpaque(true);
			break;
		case obstacle:
			this.setForeground(new Color(128,0,0));
			this.setText("♦");
			break;
		default:
			this.setForeground(fond);
			this.setIcon(null);
			this.setText(" ");
			this.setOpaque(false);
			revalidate();
		}
	}
	
	//mï¿½thodes listener
	@Override
	public void mouseClicked(MouseEvent e) {
		controlleur.getAdaptateurPlateau().caseClicked(this);
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		controlleur.setCaseAbonne(this);
	}

	@Override
	public void mouseExited(MouseEvent e) {		
		controlleur.setCaseAbonne(null);
	}

	@Override
	public void mousePressed(MouseEvent e) {
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		
	}
		
	
	
}


